<?php
include_once "xAP-functions/webincludes.php";

// build search list
$id=intval($_GET["id"]);
$startdate=intval($_GET["st"]);
$enddate=intval($_GET["en"]);

if ($id>0){

	$sql="select Location from xAP_Pictures_Source where SourceID=".$id;
	$results=dbquery($sql);
	if($startdate==0){
		$startdate=strtotime(" - 2 hours");
		$enddate=time();
	}
	
	$sql="SELECT CreatedDateStamp,ItemID FROM xap_pictures_item 
	where SourceID=".$id." 
	and createddatestamp between '".date("Y-m-d H:i:s",$startdate)."' and '".date("Y-m-d H:i:s",$enddate)."'
	order by ItemID ";
	//SELECT * FROM xap_pictures_item where createddatestamp between '2008-12-25 00:00:00' and '2008-12-25 23:59:59'
	
	//echo $sql;
	$results=dbquery($sql);
	//echo $sql;
	$hr=99;
	foreach($results as $v){
		$dt=substr(date("i",strtotime($v["CreatedDateStamp"])),0,1);
		
		if($hr!=$dt ){
			if($hr!=99){echo "<BR>";}
			echo "<B>".date("H:",strtotime($v["CreatedDateStamp"])).$dt."0</B><BR>";
			$hr=$dt;
		}
		echo "<img src='image.php?id=".$v["ItemID"]."&type=1' title='".$v["CreatedDateStamp"]."' width=160 height=120>";
	}
}
?>